<?php //echo "<pre>"; print_r($selectedUser);die();?>
<?php $this -> load -> view('header'); ?>
<!-- BEGIN CONTAINER -->
<div class="page-container row-fluid">
	<?php //$this->load->view('sidebar');?>
	<!-- BEGIN PAGE -->
	<div class="page-content">
		<!-- BEGIN PAGE CONTAINER-->
		<div class="container-fluid">
			<!-- BEGIN PAGE HEADER-->
			<div class="row-fluid">
				<div class="span12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title"> Pengaturan</h3>
					<?php $this -> load -> view('breadcrumb'); ?>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<!-- END PAGE HEADER-->
			<div class="row-fluid">
				<div class="span4">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="portlet box blue">
						<div class="portlet-title">
							<h4><i class="icon-edit"></i>Tambah Propinsi</h4>
							<!--<div class="tools" >
								<a href="javascript:;" class="reload"></a>
							</div>-->
						</div>
						<div class="portlet-body">
							<form id="userForm" action="<?php echo base_url()?>administration/savePropinsi" method="post" class="form-horizontal">
							<input type="hidden" name="Propinsi.id" value="<?php if($propinsi != null) echo $propinsi->getId(); else echo '';?>"/>
					           <div class="control-group">
					              <label class="control-label">Nama Propinsi</label>
					              <div class="controls">
					                  <input type="text" class="span12" name="Propinsi.nama" id="pPropinsiNama" value="<?php if($propinsi != null) echo $propinsi->getNama(); else echo '';?>"/>
					              </div>
					           </div>
					           <div class="form-actions">
									<button type="submit" class="btn blue" id="saveBtn">
										<i class="icon-ok"></i> Simpan
									</button>
									<button type="button" class="btn" id="cancelBtn">
											Batal
									</button>
								</div>
					       </form>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
				<div class="span8">
					<div class="portlet box blue">
						<div class="portlet-title">
							<h4><i class="icon-edit"></i>Daftar Propinsi</h4>
							<!--<div class="tools" >
								<a href="javascript:;" class="reload"></a>
							</div>-->
						</div>
						<div class="portlet-body">
								<table class="table table-striped table-hover table-bordered" id="daftarPropinsi">
								<thead>
									<tr>
										<th>Nama Propinsi</th>
										<th>Tindakan</th>
									</tr>
								</thead>
								<tbody>
									
									<?php 
										foreach ($propinsis as $propinsi){
											echo '<tr>
													<td>'.$propinsi->getNama().'</td>
													<td>
														<a class="btn blue mini" href="'.base_url().'administration/propinsiList/'.$propinsi->getId().'">Edit</a>&nbsp;
														<!-- <a class="btn red mini" href="">Hapus</a> -->
													</td>
												</tr>';		
										}
									
									?>
																	
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- END PAGE CONTAINER-->
	</div>
	<!-- END PAGE -->
</div>
<!-- END CONTAINER -->

<?php $this->load->view('footer')?>

<script>
	$(document).ready(function() {
		oTable = $('#daftarPropinsi').dataTable({
          "bProcessing" : true,
          "bScrollCollapse" : true,
          "bSort" : true,
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ Propinsi per halaman",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "order": [[ 0, "asc" ]]
        });
		
		
		$("#addUserModal").draggable({
		      handle: ".modal-header"
		}); 
		 
		$("#addUserModal" ).dialog({
		      height: 300,
		      width: 400,
		      modal: true
		 }); 
		$('#cancelBtn').click(function (event){			
			event.preventDefault();
			$('#pUserId').val("");
			$('#pPassword').val("");
			$('#pJabatan').val("-1");
			$('#pJabatan').trigger("liszt:updated");
			//$("#pProfil").multiselect("clearSelection");
			//$("#pProfil").multiselect( 'refresh' );
			//$("#pProfil > option").attr("selected",false);
			$("#pProfil option:selected").removeAttr("selected");
			$('#pProfil').trigger("liszt:updated");			
			window.location="<?php echo base_url().'administration/propinsiList';?>"
		});
		
	/*	$('#pUserId').keypress(function (e) {
		    var regex = new RegExp("^[a-zA-Z0-9]+$");
		    var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
		    if (regex.test(str)) {
		        return true;
		    }
		    e.preventDefault();
		    return false;
	}); */
		
		$('#saveBtn').click(function(event){
			/*  validasi */
			event.preventDefault();
			/*if ($('#distrik').val() == "-1"){
				alert('District cannot be null...');
				return;
			}*/
			if ($('#pUserId').val() == ""){
				alert('Silahkan memasukkan nama pengguna');
				return;
			}
			
			if ($('#pUserId').val() == ""){
				alert('Silahkan memasukkan nama pengguna');
				return;
			}
			
			
	  		$('#userForm').submit();
	  	});
	});
</script>